<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件</title>
</head>

<body>
    <div><span>选择</span></div>
    <div>
        <select name="" id="myselect" oninput="handleSelectChange()">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
        </select>
    </div>
<!-- 1 -->
    <script>
         function handleSelectChange() {
        const selectedValue = document.getElementById('myselect').value;
        console.log('Selected Value:', selectedValue);
    }
    </script>

    <!-- 2 -->
    <!-- <script>
        const selectElement = document.getElementById('myselect');
        selectElement.oninput = function() {
            const selectedValue = this.value;
            console.log('Selected Value:', selectedValue);
        };
    </script> -->
    <!-- 3 -->
    <!-- <script>
        function handleSelectChange() {
            const selectedValue = document.getElementById('myselect').value;
            console.log('Selected Value:', selectedValue);
        }
    
        const selectElement = document.getElementById('myselect');
        selectElement.addEventListener('input', handleSelectChange);
    </script> -->
</body>

</html>